<template>
  <div class="container">
    <div class="back-btn" @click="handleBack" :class="{ 'fade-out': isLeaving }">
      <van-icon name="arrow-left" />
    </div>
    
    <div class="card-wrapper">
      <div class="card" :class="{ 'slide-up': isLeaving }">
        <h2 class="card-title">订单详情</h2>
        
        <div class="info-row">
          <div class="info-label">预约时间</div>
          <div class="info-value">{{ formData.endTime }}</div>
        </div>
        
        <div class="info-row">
          <div class="info-label">联系方式</div>
          <div class="info-value">{{ formData.contact }}</div>
        </div>
        
        <div class="description">
          <div class="info-label description-title">详细描述</div>
          <div class="description-content">{{ formData.content }}</div>
        </div>
        
        <div class="image-gallery">
          <img src="../assets/avatar.jpg" class="gallery-image" />
          <img src="../assets/avatar.jpg" class="gallery-image" />
        </div>
        
        <div class="submit-btn-container">
          <van-button class="order-btn" @click="handleSubmit">接 单</van-button>
        </div>
      </div>
    </div>
    <div class="background-image" :class="{ 'fade-out': isLeaving }">
      <img src="../assets/1.jpg" alt="背景图片" />
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router'

const router = useRouter()
const route = useRoute()
const taskId = ref('')
const isLeaving = ref(false)

const formData = ref({
  task: '前端',
  endTime: '2025年10月1日',
  content: '开发小程序，实现用户登录、注册、浏览商品、下单等功能。开发小程序，实现用户登录、注册、浏览商品、下单等功能。开发小程序，实现用户登录、注册、浏览商品、下单等功能。',
  contact: '12345678901'
})

const handleBack = () => {
  isLeaving.value = true
  setTimeout(() => {
    router.back()
  }, 300)
}

const goBack = () => {
  router.back()
}

const handleSubmit = () => {
  alert('接单成功')
  setTimeout(() => router.back(), 1500)
}
</script>

<style scoped>
.container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: linear-gradient(to bottom, #979797, #ffffff);
  position: relative;
}

.back-btn {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 36px;
  height: 36px;
  background-color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 4px 4px 4px rgba(0, 0, 0, 0.4);
  z-index: 10;
  transition: opacity 0.3s ease-out;
}

.background-image {
  position: absolute;
  top: 0px;
  left: 0;
  width: 100%;
  z-index: 1;
  text-align: center;
  transition: opacity 0.4s ease-out;
}

.fade-out {
  opacity: 0;
}

.card-wrapper {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding: 20px;
  min-height: 100vh;
}

.card {
  width: 100%;
  max-width: 400px;
  background-color: white;
  border-radius: 20px;
  padding: 20px;
  border: 2px solid #000;
  margin-bottom: 50px;
  box-shadow: 12px 10px 10px rgba(0, 0, 0, 0.4);
  animation: slideDown 0.8s ease-out;
  transition: transform 0.5s ease-out, opacity 0.5s ease-out;
}

.slide-up {
  transform: translateY(-100%);
  opacity: 0;
}

@keyframes slideDown {
  0% {
    transform: translateY(-100%);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

.card-title {
  text-align: center;
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid #656565;
}

.info-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 15px;
}

.info-label {
  font-weight: bold;
  color: #333;
}

.info-value {
  color: #666;
}

.description {
  margin-bottom: 20px;
}

.description-content {
  margin-top: 10px;
  color: #333;
  line-height: 1.5;
  font-size: 14px;
}

.image-gallery {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.gallery-image {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #090909;
}

.submit-btn-container {
  margin-top: 20px;
}

.order-btn {
  width: 100%;
  height: 45px;
  font-weight: bold;
  border-radius: 25px;
  background: #333;
  border: 1px solid #333;
  color: white;
  font-size: 16px;
  box-shadow: 6px 6px 10px rgba(0, 0, 0, 0.4);
}

.order-btn:active {
  opacity: 0.9;
}

.background-image {
  position: absolute;
  top: 0px;
  left: 0;
  width: 100%;
  z-index: 1;
  text-align: center;
}

.background-image img {
  max-width: 100%;
  height: auto;
}

.card-wrapper {
  position: relative;
  z-index: 2;
}
.description-title {
  text-align: center;
  width: 100%;
  margin-bottom: 10px;
}
</style>